# Maintainer: Michal Tvrznik <emporeor@gmail.com>
pkgname=emptty
pkgver=0.11.0
pkgrel=0
pkgdesc="Dead simple CLI Display Manager on TTY"
url="https://github.com/tvrzna/emptty"
arch="all"
license="MIT"
makedepends="git go linux-pam-dev libx11-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/tvrzna/emptty/archive/v$pkgver.tar.gz
	alpine-pam.patch
	"
subpackages="
	$pkgname-doc
	$pkgname-openrc
"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mkdir -p dist/
	go build -o dist/emptty
}

check() {
	LANG=en_US.UTF-8 go test ./...
}

package() {
	# man page
	install -D res/emptty.1 $pkgdir/usr/share/man/man1/emptty.1

	# PAM file
	install -Dm 644 res/pam $pkgdir/etc/pam.d/emptty

	# config file
	install -Dm 644 res/conf $pkgdir/etc/emptty/conf

	# openrc service unit
	install -Dm 755 res/openrc-service $pkgdir/etc/init.d/emptty

	# binary
	install -Dm 755 dist/emptty $pkgdir/usr/bin/emptty
}

sha512sums="
05ca5968742e139dd1e4579b9863ba69cf958d3a7a4ae85429b30be4464635a24130d43016c63eb62f444218ebad1a1dbbe6c63379c174dd8a290d79c5102b1a  emptty-0.11.0.tar.gz
db640a99d46511dcc6ec9fce74fd2b3877e098f2886839f95b5770bf63a49d77cee1a433963dd92beedcba788aa113a47de98d29d0e5f0edc6626f074c4585b2  alpine-pam.patch
"
